<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>    
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<%@ include file="/WEB-INF/jsp/kt/common/inc.jsp" %>
<title>选人</title>
</head>
<script type="text/javascript">
    var projectRoleUserList = new Array();
    var roleId = "${roleId}";
    var userId = "${userId}";
	$(function (){
        var currentProjectRoleUserList = parent.$("#projectRoleUserList").bootstrapTable('getData');
        console.info(currentProjectRoleUserList);
        console.info(2);
         if(currentProjectRoleUserList.length > 0){
             for(var i = 0 ; i < currentProjectRoleUserList.length; i++){
                 var userTaskProject = new Object();
                 userTaskProject.roleId =  currentProjectRoleUserList[i].roleId;
                 userTaskProject.roleName =  currentProjectRoleUserList[i].roleName;
                 userTaskProject.userId = currentProjectRoleUserList[i].userId;
                 userTaskProject.userName = currentProjectRoleUserList[i].userName;
                 projectRoleUserList.push(userTaskProject);
             }
         }


		 var uri = "";
         uri="projectRoleUser/selectRoleUserFourYard?roleId="+roleId+"&userId="+userId;
         $("#selectIframe").attr("src","${_baseUrl}/"+uri);
	     $("input[type=radio][name=viewType]").change(function(){
	        var v = $(this).val();
	        if(v == '1'){
	        	uri="projectRoleUser/selectRoleUserFourYard";
	        }else if(v == '0'){
	        	uri="projectRoleUser/selectDepartUserFourYard";
	        }

            if(uri.indexOf("?") != -1){
                uri= uri+"&random="+Math.random();
            }else {
                uri= uri+"?random="+Math.random();
            }

	        $("#selectIframe").attr("src","${_baseUrl}/"+uri);
         });
	    

		
		$("#submit").click(function (){
			var selectIframe = document.getElementById('selectIframe');
			selectIframe.contentWindow.save();
		});
		
		$("#cancel").click(function (){
			var index = parent.layer.getFrameIndex(window.name);  
			parent.layer.close(index); 
		});

		$("#search").click(function (){
			var value = $("#searchValue").val();
			var selectIframe = document.getElementById('selectIframe');
			selectIframe.contentWindow.search(value);
		});

		$("#searchValue").keydown(function(event) {//给输入框绑定按键事件
		    if(event.keyCode == "13") {//判断如果按下的是回车键则执行下面的代码
		    	var value = $("#searchValue").val();
				var selectIframe = document.getElementById('selectIframe');
				selectIframe.contentWindow.search(value);
		  	}

            if(event.keyCode =="32"){
                var value = $("#searchValue").val();
                var selectIframe = document.getElementById('selectIframe');
                selectIframe.contentWindow.search(value);
            }
		});

		$("#save").click(function (){
			var selectIframe = document.getElementById('selectIframe');
			selectIframe.contentWindow.save1();
			layer.msg("保存成功");
		});
	});

	function closeOpen(){
        var index1 = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
        parent.layer.close(index1);
    }
</script>
<style type="text/css">
	.table_common_info{margin-top: 5px;margin-bottom: 0px;margin-right:0px;margin-left: 20px;}	
	.func_search_div{width: 250px;}
	.func_search input{width: 215px;}
	.search_container{float: right;margin-right: 30px;}
	.important_Preservation{margin-bottom: 0px;}
</style>
<body>
<div class="func_bar" style="margin: 13px auto 10px;">
    <c:if test="${empty roleId}">
        <div class="table_common_info">
             <span style="float: left;display:inline-block;height:30px;line-height:15px;margin-left:5px;">查询方式：</span>
                <div class="radio_a">
                    <input class="radio_a_input" id="item1" type="radio" name="viewType" value="1" checked>
                    <label class="radio_a_label" for="item1"></label>
                    <span style="margin-left: 5px">按角色</span>
                </div>
                <div class="radio_a" style="margin-left:20px">
                    <input class="radio_a_input" id="item2" type="radio" name="viewType" value="0">
                    <label class="radio_a_label" for="item2"></label>
                    <span style="margin-left: 5px">按组织</span>
                </div>
        </div>
    </c:if>
    <div class="search_container">
        <c:if test="${empty roleId}">
            <div class="func_search">
                    <div class="func_search_div"></div>
                   <input type="text" name="user_date" value="" id="searchValue" placeholder="请输入人员名称"/>
                   <a class="search_btn" id="search" href="javascript:;"></a>
            </div>
        </c:if>
	</div>
</div>
<div style="margin-top:40px;width: 98%;margin: auto;" id='iframeCont' class='iframeCont'>
    <iframe width='100%' height='100%' id="selectIframe" frameborder="none" scrolling="auto" ></iframe>
</div>
<div class="important_Preservation_c" >
    <div class="important_Preservation">
        <c:if test="${empty roleId}">
    	    <a href="javascript:;" id="save" class="submit" >保存</a>
        </c:if>
        <a href="javascript:;" id="submit" style="margin-left: 20px;">提交</a>
        <a href="javascript:;" id="cancel">取消</a>
    </div>
</div>
</body>

<script type="text/javascript">
    var  resizeTimer = null;
    window.onload = function(){
        initHeight();
    }

    function initHeight(){
        var topH = 0;
        if(navigator.userAgent.indexOf("MSIE")>0 || navigator.userAgent.indexOf("like Gecko")>0) {//IE浏览器
            initheight = document.documentElement.clientHeight-topH;
        }
        if(navigator.userAgent.indexOf("Firefox")>0){//Firefox浏览器
            initheight = document.documentElement.clientHeight-topH;
        }
        if(navigator.userAgent.indexOf("Opera")>0){//Opera浏览器
            initheight = document.body.clientHeight-topH;
        }
        if(navigator.userAgent.indexOf("Chrome")>0){//Chrome谷歌浏览器
            initheight = document.documentElement.clientHeight-topH;
        }
        if(navigator.userAgent.indexOf("Safari")>0){//Safari浏览器
            initheight = document.documentElement.clientHeight-topH;
        }
        $("#iframeCont").css( "height",initheight -115 );
    }
</script>
</html>